<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
	#boerte{
		width: 260px;
		position: absolute;
		top: 50px;
		left: 0px;
	}
</style>
<script type="text/javascript">
	window.onload = function(){
		var btn = document.getElementById('btn');//抓到按钮元素
		var boerte = document.getElementById('boerte');//抓到博尔特

		var timer;
		// 给按钮加一个单击事件
		btn.onclick = function(){
			clearInterval(timer);
			// 设立运动定时器
			timer = setInterval(function(){
				// 获得图片的left值
				var old_left = parseInt(boerte.style.left);
				//计算新的left值
				var new_left = old_left+1;
				// 将新的left值赋值回去
				boerte.style.left = new_left+'px';

				// 判断是否应该停止了
				if(new_left==500){
					clearInterval(timer);
				}
			},5)
		}

	}
</script>
</head>

<body>

<input type="button" value="走你~~~~" id="btn" />
<br /><br />

<img src="boerte.jpg" style="left:0px;" id="boerte" />



</body>
</html>
